<script type="text/javascript" src="__PUBLIC__/statics/js/jquery.masonry.min.js"></script>  
<script type="text/javascript">
$(document).ready(function(){
	/**
	 *推广商品替换
	 */
	//容器宽度
	var ww = $(document.body).width();
	var sw = ww%240;
	var dw = ww-sw;
	$(".content_fluid").css('width',dw);
	$(".header_top").css('width',dw);
	//容器
	var $container = $('.content');
	//当前页数
	var nowPage = parseInt($(".nowPage").text());
	//获取推广状态
	var spread_status=$("#spread_status").text();
	//推广标识
	var sign = true;
	//不是第一页不推广	
	if(nowPage > '1' || spread_status == '0'){
		sign = false;
	}
	if(sign == true){
		
		//获取图片高度
		$.each($(".pic"),function(){
			var imgl = new Image();
			imgl.src = $(this).find(".item_img").attr('src');

			var heightl;
			heightl = (200/imgl.width)*imgl.height;

			$(this).css('height',heightl);
			$(this).find('.item_img').attr('height',heightl);
		});
		
		//执行超时检查
        setTimeout(function(){
            checkajax();
        },100);
		
		//获取位置
		var spread_position=$("#spread_position").text();
		//插入推广商品
		var itemHTML='<div class="poster_grid poster_wall pins col co xiayijian"><div class="new_poster" id="spread"></div></div>';
		if(nowPage){
			var s='.co:eq('+(spread_position-1)+')';
			var t=$(s);
			if(t[0]){
				$(s).before(itemHTML);
			}else{
				$container.append(itemHTML);
			}
		}else{
			$container.append(itemHTML);
		}
		var item_info=$("#spread_info").html();
		if(item_info.match('div') || item_info.match('DIV')){
			document.getElementById("spread").innerHTML=item_info;
		}else{
			$(".xiayijian").remove();
		}

		function checkajax(){
			//瀑布流布局	
			$container.masonry({
				itemSelector : '.col',
				columnWidth : 120
			});
        }
	}else{
		//获取图片高度
		$.each($(".pic"),function(){
			var imgl = new Image();
			imgl.src = $(this).find(".item_img").attr('src');

			var heightl;
			heightl = (200/imgl.width)*imgl.height;
			
			$(this).css('height',heightl);
			$(this).find('.item_img').attr('height',heightl);
		}); 
		//瀑布流布局
		$container.masonry({
			itemSelector : '.col',
			columnWidth : 120
		});
	}
	//窗口变化
	$(window).resize(function() {
		var ww = $(document.body).width();
		var sw = ww%240;
		var dw = ww-sw;
		$(".content_fluid").css('width',dw);
		$(".header_top").css('width',dw);
	});
	/**
	 *加载数据
	 */
	//锁定标识
	var key = true;
	//加载计数
	var i= 1;	
	//窗口绑定滚动事件
	$(window).bind("scroll",function() {
		//高度参数
		var l=$(document).scrollTop() + $(window).height();
		var h=$(document).height();
	    //判断窗口的滚动条是否接近页面底部，自定义500
	    if (l > h - 500 && l < h && key==true) {
	        key = false;
			//获取url
			var url = $("#url").text();
			if(!url){
				return false;
			}
			//获取id
			var id = $("#id").text();
			//获取排序
			var sortby = $(".right_f .active").attr('name');
			//获取价格
			var price = $(".left_f .active").attr('name');
			//请求页数
			var p = (nowPage-1)*5+i+1;
			//总记录数
			var totalRows = parseInt($(".totalRows").text());
			if(totalRows <= ((nowPage-1)*100)+20 || !p){
				return false;
			}
	  		if (i < 5) {
	  			//显示加载图标，隐藏分页
				$(".loading").show();
				$(".page").hide();
	  			//如果存在的话，用ajax获取数据
	  			$.ajax({
	  				type: "get",
	  				url: url,
	  				data: {id:id, sortby:sortby, price:price, p:p},
	  				success: function(data) {
	  					//隐藏加载图标，显示分页
	  					$(".loading").hide();
	  					$(".page").show();
	  					key = true;
	  					//重新加载js
	  					$.ajax({
	  						url: "__TMPL__Public/js/common.js",
	  						dataType: "script",
	  						global: false
	  					});				
	  					//获取总页数
	  					var totalPages = $(data).find(".totalPages").text();
	  					//将返回的数据进行处理，挑选出class是co的内容块
	  					var $res = $(data).find(".co");
	  					//获取图片高度
	  					$.each($res.find(".pic"),function(){
	  						var imgl = new Image();
	  						imgl.src = $(this).find(".item_img").attr('src');

	  						var heightl;
	  						heightl = (200/imgl.width)*imgl.height;

	  						$(this).css('height',heightl);
	  						$(this).find('.item_img').attr('height',heightl);
	  					});
						//替换图片src								
	  					$.each($res.find(".item_img"),function(){
		  					$(this).attr('src1',$(this).attr('src'));
		  					$(this).removeAttr('src');
	  					})
	  					//结合masonry插件，将内容append进ID是content的内容块中
	  					$container.append($res.fadeIn()).masonry('appended', $res);
	  					//加载图片
	  					$.each($res.find(".item_img"),function(){
	  						$(this).attr('src',$(this).attr('src1'));
	  						$(this).removeAttr('src1');
	  					})
	  					//加载4页后显示分页
	  					if (((nowPage-1)*5+i+1) < totalPages) {
	  						i++;
	  					} else {
	  						i=5;
	  					}
	  				}
	  			})
	  		}
	    }
	});
});
</script>
<div class="goods_wall content">
<if condition="(MODULE_NAME neq 'Search') AND (MODULE_NAME neq 'Shop')">
	<div class="corner_notic col">
		<div class="rec_nav red_tb">
		<volist name="snav" id="vsn">
			<h2 ><img src="<php>echo C('web_path').ltrim($vsn['img'],'/');</php>" title="{$vsn.name}" alt="{$vsn.name}" />{$vsn.name}</h2>
			<div class="category">
				<volist name="vsn['tags']" id="vsnt" offset="0" length='12'>
					<a class="<if condition="$vsnt['id'] eq $tag_id">active<elseif condition="($vsnt['id']%5) eq '0'"/>ishot</if>" href="{:get_url('tag',$vsnt['id'],'cate')}">{$vsnt.name}</a>
				</volist>
					<div class="clear_f"></div>
			</div>
		</volist>
<if condition="$shop_list">
<h2 >店铺</h2>
<div class="dianpu">
	<ul>
	<volist name="shop_list" id="voShop" offset="0" length="12">
	<li><a href="{:get_url('index',$voShop['id'],'shop')}">
		<img title="{$voShop.name}" alt="{$voShop.name}" src=<if condition="$voShop['img']">"{$voShop.img}"<else/>__TMPL__Public/img/undefined.jpg</if>>
	</a></li>
	</volist>
	</ul>
	<div class="clear_f"></div>
</div>
</if>
		<div class="clear_f"></div>

		</div>
	</div>
</if>
  <div id="spread_info" style="display:none;">{$spread_info}</div>
<!--单个商品列表-->
	<volist name="items_list" id="voItems">
	<div class="poster_grid poster_wall pins col co">
			<div class="new_poster">
				<div class="np_pic hover_pic pic">
					<div class="no"></div>
					<a class="pic_load" href="{:get_url('index',$voItems['id'],'item')}" target="_blank"><img class="goods_pic item_img" width="200" <if condition="$voItems['img'] neq ''">src="{$voItems.img|get_img=###,210}"<else/>src="__TMPL__Public/img/undefined.jpg"</if> title="{$voItems.title}" alt="{$voItems.title}"></a>
					<div class="like_merge" style="display:none;">
						<a class="right_f poster_forward" href="{:get_url('addAlbum',$voItems['id'],'album')}" target="_blank"><em class="lm_shouji">&nbsp;</em>加入专辑</a>
					</div>
				</div>
				<div class="comm_box twiiter_box">
					<p class="posterContent">{$voItems.title}</p>
					<p class="comm_num l20_f">
						<a class="poster_comment pl" href="{:get_url('index',$voItems['id'],'item')}#comm">评论 <span class="poster_comment_num">{$voItems.comments}</span></a>
						<a class="left_f poster_likes likes" href="javascript:;"> <b class="likes_status s1" item_id="{$voItems['id']}"><i class=<if condition="$likes[$voItems['id']] eq 1">""<else/>"lm_love2"</if> id="like_{$voItems['id']}">&nbsp;</i><span class="sl"><if condition="$likes[$voItems['id']] eq 1">已喜欢<else/>喜欢</if></span></b> <span class="red_f poster_like_num" id="{$voItems['id']}">{$voItems.likes}</span> </a>
						<input type="hidden" name="" id="like_post_action" value="{:get_url('createlike','','user')}"><input type="hidden" name="" id="like_post_location" value="{:get_url('login','','user')}">
					</p>
					<div class="clear_f"></div>
				</div>		
				<div class="np_share comment_panel">
					<a class="avatar32_f trans07 userInfoTips" href="{:get_url('index',$voItems['uid'],'user')}" target="_blank"><img onerror="this.src='__PUBLIC__/statics/images/avatar-60.png'" src=<if condition="$voItems['userimg'] neq ''">"{:C('web_path')}Uploads/avatar_small/{$voItems.userimg}"<else/>"__PUBLIC__/statics/images/avatar-60.png"</if>></a>
					<p class="ml40_f commentHover">
						<a class="fb_f" href="{:get_url('index',$voItems['uid'],'user')}" target="_blank">{$voItems.username}</a>
						<span>分享于{$voItems.add_time|date='Y年m月d日 H:i:s',###}</span>
					</p>
					<div class="clear_f"></div>
				</div>
				<present name="voItems['ablum_info']">
				<div class="np_share comment_panel">
					<a class="avatar32_f trans07 userInfoTips" href="{:get_url('index',$voItems['ablum_info']['uid'],'user')}" target="_blank"><img onerror="this.src='__PUBLIC__/statics/images/avatar-60.png'" src=<if condition="$voItems['ablum_info']['img'] neq ''">"{:C('web_path')}Uploads/avatar_small/{$voItems.ablum_info.img}"<else/>"__PUBLIC__/statics/images/avatar-60.png"</if>></a>
					<p class="ml40_f commentHover">
						<a class="fb_f" href="{:get_url('index',$voItems['ablum_info']['uid'],'user')}" target="_blank">{$voItems.ablum_info.uname}</a>
						<span>分享到</span><a href="{:get_url('albumDetail',$voItems['ablum_info']['id'],'user')}" target="_blank">#{$voItems.ablum_info.title}#</a>
					</p>
					<div class="clear_f"></div>
				</div>
				</present>
				<present name="voItems['commnets_info']">
				<div class="comm_share commentHover">
					<a class="avatar32_f trans07 userInfoTips" href="{:get_url('index',$voItems['commnets_info']['uid'],'user')}" target="_blank"><img onerror="this.src='__PUBLIC__/statics/images/avatar-60.png'" src=<if condition="$voItems['commnets_info']['img'] neq ''">"{:C('web_path')}Uploads/avatar_small/{$voItems.commnets_info.img}"<else/>"__PUBLIC__/statics/images/avatar-60.png"</if>></a>
					<p class="ml40_f">
						<a class="fb_f" href="{:get_url('index',$voItems['commnets_info']['uid'],'user')}" target="_blank">{$voItems.commnets_info.name}</a>
						<span class="gray_f">{$voItems.commnets_info.info}</span>
					</p>
					<div class="clear_f"></div>
				</div>
				</present>
			</div>
	</div>
	</volist>
<!--单个商品列表-->
</div>
	<div class="spinner botSpinner none_f"></div>
	<div class="clear_f"></div>
	
<div class="paging_panel p_f">
	<div class="pageNav bgcnt">
	 	<div class="loading" style="width:32px;height:32px;margin:0 auto;display:none;"><img src="__PUBLIC__/statics/images/loading_d.gif"></div>
		<div class="page">{$page}</div>
	</div>
</div>	
	<div class="ads_banner ads_bottom none_f"></div>
